package com.xk.order.config;

import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayConstants;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WxPayConfiguration {
    //注入config
    @Bean
    @ConfigurationProperties("xk.pay")
    public PayConfig payConfig(){
        return new PayConfig();
    }
    //第一个参数是config（即PayConfig）,第二个参数是签名的类型算法
    @Bean
    public WXPay wxPay(PayConfig payConfig){

        return new WXPay(payConfig, WXPayConstants.SignType.HMACSHA256);

    }

}
